package yz.mr.partitioner;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class PartitionDriverMapper extends Mapper<LongWritable, Text,Text,StudentText> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, StudentText>.Context context) throws IOException, InterruptedException {
        String[] stu = value.toString().split("\t");
        String id = stu[0];
        String[] otherInfo = stu[1].split(",");
        StudentText studentText = new StudentText(id,otherInfo[0],otherInfo[1],otherInfo[2],otherInfo[3],Integer.parseInt(otherInfo[4]));
        context.write(new Text(studentText.getClazz()),studentText);
    }
}
